<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <link rel="stylesheet" href="../css/animate.css">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>{{title}} </h2>
        <myhead></myhead>
        <parent
            num="1314"
            age="18"
            word="Day Day Up"
        ></parent>
        
    </div>

    <template id="parent">
        <div>
            <h2>parent = parent - 父组件</h2>
            <h2>{{num}} -- {{age}} -- {{word}}</h2>
            <hr>
            <childone
                :pro="pro"
                :city="city"
                :ared="ared"
                :address="address"
            ></childone>      
            <hr>
            <childtwo
                :prop-a="1314"
                prop-b="Day Day Up"
                :prop-c="flag"
                prop-d="努力学习哒~~"
            ></childtwo>
        </div>
    </template>

    <template id="childone">
        <div>
            <h2>childone = 1</h2>
            <h2>地址是 {{pro}} -- {{city}} -- {{ared}} -- {{address}} </h2>
        </div>
    </template>

    <template id="childtwo">
        <div>
            <h2>childtwo = 2</h2>
            <h2>我的props === {{propA}} - {{propB}} - {{propC}} - {{propD}} </h2>
        </div>
    </template>


    <script>
        Vue.component('myhead',{
            template:"<h1>越努力越幸运</h1>"
        })

        Vue.component('parent',{
            template:'#parent',
            data(){
                return{
                    pro:'湖北省',
                    city:'武汉市',
                    area:'江夏区',
                    address:'金融港B18',
                    flag:!!1
                }
            },
            props:['num','age','word'],

            components:{
                childtwo:{
                    template:'#childtwo',
                    props:{
                        propA:Number,
                        propB:String,
                        propC:Boolean,
                        propD:[String,Number]
                    }
                }
            }
        })

        Vue.component('childone',{
            template:"#childone",
            props:{
                pro:String,
                city:{
                    type:String,
                },
                area:{
                    type:[String,Number],
                    default:'null'
                },
                address:{
                    type:[String,Function],
                    default:''
                }
            }
        })

       

    
        const vm = new Vue({

            data:{
                title:"Vue component 组件传参(props)"
            },
            components:{ //局部变量
                frist:{
                    template:"<h3>frist - Vue 组件初始化</h3>"
                }
            },
            mounted(){
                document.getElementsByTagName("title")[0].innerHTML = this.title
            },

        }).$mount('#app')
    </script>
</body>
</html>